// JavaScript Document
var Current_Tab_Content = "Tab_1";
var Last_element;
function contractManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("contractManagementFrameset");
		frameset.rows = "*,0";
}
function orderManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("orderManagementFrameset");
		frameset.rows = "*,0";
}

function invoiceManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("invoiceManagementFrameset");
		frameset.rows = "*,0";
}
function contactManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("contactManagementFrameset");
		frameset.rows = "*,0";
}
function postManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("postManagementFrameset");
		frameset.rows = "*,0";
}

function backManagementCreateOrEditWindowsClose(){
		var frameset = parent.document.getElementById("backManagementFrameset");
		frameset.rows = "*,0";
}
function Tab_Operation(obj1)
{
	/*obj1.style.display = "";
	document.getElementById('Tab_2_sub').style.display ="none";
	document.getElementById('Tab_1_sub').style.display ="";
	document.getElementById('Tab_1').style.display ="none";
	document.getElementById('Tab_1_content').style.display ="none";
	obj2.style.display = "";*/
	Tab_Name = obj1.id;
	
	Selft_Operate(Tab_Name);
	Hidden_Element(Current_Tab_Content);
	
	Current_Tab_Content = obj1.id
	
}

function Selft_Operate(Current_TabName)
{
	Current_TabName_sub = Current_TabName + "_sub";
	Current_TabName_content = Current_TabName + "_content";
	document.getElementById(Current_TabName).style.display ="";	
	document.getElementById(Current_TabName_sub).style.display ="none";
	document.getElementById(Current_TabName_content).style.display ="";
}

function Hidden_Element(Last_TabName)
{
	Last_TabName_sub = Last_TabName + "_sub";
	Last_TabName_content = Last_TabName + "_content";
	document.getElementById(Last_TabName).style.display ="none";	
	document.getElementById(Last_TabName_sub).style.display ="";
	document.getElementById(Last_TabName_content).style.display ="none";
}

function Hide_ShowElement(menu,img1)
{
	//display = false;
	if(menu.style.display == "none")
	{
		menu.style.display ='';	
		img1.src="images/deploy.gif";
	}
	else
	{
		menu.style.display ='none';	
		img1.src="images/shrink.gif";	
	}
}

function Hide_ShowSubElement(sub_Menu_Item)
{
	//display = false;
	if(sub_Menu_Item.style.display == "none")
	{
		sub_Menu_Item.style.display ='';	
	}
	else
	{
		sub_Menu_Item.style.display ='none';		
	}
}

function Over_SelectElement(selectelement)
{
	if(selectelement == Last_element)
	{
		return;
	}
	else
	{
		selectelement.bgColor = "#EFEEEE";
	}
}

function SelectElement(selectelement)
{
	if(Last_element == null)
	{
		//selectelement.bgColor = "#D5D5D5";
		selectelement.className="effect"
		Last_element = selectelement;
	}
	else
	{
		if(Last_element == selectelement)
		{
				return;
		}
		else
		{
			//selectelement.bgColor = "#D5D5D5";
			selectelement.className="effect"
			//Last_element.bgColor = "#ffffff";
			Last_element.className = "effect_after";
			Last_element = selectelement;
		}
	}
}

function MouseOutElement(selectelement) 
{
	if(selectelement == Last_element)
	{
		selectelement.bgColor = "#D5D5D5";
	}
	else
	{
		selectelement.bgColor = "#ffffff"; 
	}
}

//invoke the class name
function ClassName(selectelement)
{
	selectelement.className = "submenu_style_font_select";
}

//for multiSelect
function groupRight(srcProperty,decProperty,moveFun) {
	  var moves=[];
    for (i = 0; i<srcProperty.options.length; i++) {
        if(srcProperty.options[i].selected){
	          moves.push([srcProperty.options[i].value,srcProperty.options[i].text]);
	          srcProperty.remove(i);
            i = i - 1;
        }
    }
    for (i=0;i < moves.length; i++) {
        var opt=moves[i];
        var element=document.createElement("OPTION");
            element.text=opt[1];
            element.value=opt[0];
        //var element = window.Option.create(opt[1],opt[0], 0);
	      element.selected="true";
	      decProperty.options.add(element);
    }
    if(moves.length>0&&moveFun && typeof(moveFun)=="function"){
      moveFun(moves);
    }
    return;
}
function groupLeft(srcProperty,decProperty,moveFun) {
	  var moves=[];
    for (i = 0; i <= decProperty.options.length - 1; i++) {
        if (decProperty.options[i].selected) {
        	  var element=document.createElement("OPTION");
            element.text=decProperty.options[i].text;
            element.value=decProperty.options[i].value;
            //var element = window.Option.create(decProperty.options[i].text, decProperty.options[i].value, 0);
            moves.push([decProperty.options[i].value,decProperty.options[i].text]);
            srcProperty.options.add(element);
        }
    }
    for (i = 0; i < decProperty.options.length; i++) {
        if (decProperty.options[i].selected) {
            decProperty.remove(i);
            i = i - 1;
        }
    }
    if(moves.length>0 && moveFun && typeof(moveFun)=="function"){
        moveFun(moves);
    }
    return;
}
function groupRightAll(srcProperty,decProperty,moveFun) {
	  var moves=[];
    /*for (i = 0; i < srcProperty.options.length; i++) {
        srcProperty.options[i].selected = true;
        var element = window.Option.create(srcProperty.options[i].text, srcProperty.options[i].value, 0);
        element.selected="true";
        decProperty.options.add(element);
    }
    for (i = 0; i < srcProperty.options.length; i++) {
        srcProperty.options[i].selected = true;
        srcProperty.remove(i);
        i = i - 1;
    }*/
    for (i = 0; i < srcProperty.options.length; i++) {
    	  moves.push([srcProperty.options[i].value,srcProperty.options[i].text]);
	      srcProperty.remove(i);
        i = i - 1;
    }
    for (i=0;i < moves.length; i++) {
        var opt=moves[i];
        var element=document.createElement("OPTION");
            element.text=opt[1];
            element.value=opt[0];
        //var element = window.Option.create(opt[1],opt[0], 0);
	      element.selected="true";
	      decProperty.options.add(element);
    }
    if(moves.length>0 && moveFun && typeof(moveFun)=="function"){
        moveFun(moves);
    }
    return;
}
function groupLeftAll(srcProperty,decProperty,moveFun) {
	  var moves=[];
    for (i = 0; i < decProperty.options.length; i++) {
        decProperty.options[i].selected = true;
        moves.push([decProperty.options[i].value,decProperty.options[i].text]);
        var element=document.createElement("OPTION");
        element.text=decProperty.options[i].text;
        element.value=decProperty.options[i].value;
        //var element = window.Option.create(decProperty.options[i].text, decProperty.options[i].value, 0);
        srcProperty.options.add(element);
    }
    for (i = 0; i < decProperty.options.length; i++) {
        decProperty.options[i].selected = true;
        decProperty.remove(i);
        i = i - 1;
    }
    if(moves.length>0 && moveFun && typeof(moveFun)=="function"){
        moveFun(moves);
    }
    return;
}
//end
function insertRow(srcProperty,textName,tableName){
       var tab;
       var tempRowObj;
       var tempCellObj;
       for (i = 0; i < srcProperty.options.length; i++) {        
        if(srcProperty.options[i].selected){
           var textID=srcProperty.options[i].value;
           tempRowObj=document.all(tableName).insertRow();
           tempRowObj.id=textID;           
	       tempCellObj=tempRowObj.insertCell();
	       tempCellObj.align="center";
	       tempCellObj.innerHTML="<td><input name='"+textName+"' accept='required' title='CASID' type=text ></td>";
        }


    }
 }
 
 function insertAllRow(srcProperty,textName,tableName){
       var tab;
       var tempRowObj;
       var tempCellObj;
       for (i = 0; i < srcProperty.options.length; i++) {    
        
           var textID=srcProperty.options[i].value;
           tempRowObj=document.all(tableName).insertRow();
           tempRowObj.id=textID;
	       tempCellObj=tempRowObj.insertCell();
	       tempCellObj.align="center";
	       tempCellObj.innerHTML="<td><input name='"+textName+"' accept='required' title='CASID' type='text' ></td>";
    }
 }

 function deleteRow(decProperty,tableName){
       var tab;
       var tempRowObj; 
       tab=document.all(tableName);      
       for (i = 0; i < decProperty.options.length; i++) {        
        if(decProperty.options[i].selected){            
            var textID=decProperty.options[i].value;         
            for(var j=0;j<tab.rows.length;j++){
               tempRowObj=tab.rows(j);
               if(tempRowObj.id==textID){
                   tab.deleteRow(j);
                   j--;
               }
              
           }
        }
       
     }
}

function deleteAllRow(decProperty,tableName){
       var tab;
       var tempRowObj;
       tab=document.all(tableName); 
       for (i = 0; i < decProperty.options.length; i++) {        
        var textID=decProperty.options[i].value;
              
        for(var j=0;j<tab.rows.length;j++){             
            tempRowObj=tab.rows(j);            
            if(tempRowObj.id==textID){
               tab.deleteRow(j);
               j--;
            }
               
        }
     }
}
function findOptionSize(decOption,targetDiv){
	var decOptionObj=document.getElementById(decOption);
	var targetDivObj=document.getElementById(targetDiv);
	if(decOptionObj && targetDivObj){
		targetDivObj.innerText=decOptionObj.options.length;
	}
}
